const logger = require('electron-log')
const {app} = require('electron')
const path = require("path");
 
logger.transports.file.level = 'info'
logger.transports.console.level = false
let date = new Date();
let dateStr = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
console.log(dateStr);
let logname = 'logs/' + dateStr+ '.log';

let appDir = app.getAppPath();
if(appDir.endsWith("app.asar")) {
    appDir = path.resolve(appDir, "..");
    appDir = path.resolve(appDir, "..");
}
logger.transports.file.resolvePath=()=>path.join(appDir,logname);
logger.transports.file.maxSize = 1002430 // 10M
logger.transports.file.format = '[{y}-{m}-{d} {h}:{i}:{s}.{ms}] [{level}]{scope} {text}'

module.exports = {
  info (param) {
    logger.info(param)
  },                   
  warn (param) {
    logger.warn(param)
  },
  error (param) {
    logger.error(param)
  },
  debug (param) {
    logger.debug(param) 
  },
  verbose (param) {
    logger.verbose(param)
  },
  silly (param) {
    logger.silly(param)
  }
}